package logic

import (
	"cart_srv/model/redis"
	"context"

	"cart_srv/cart"
	"cart_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CheckedCartLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCheckedCartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckedCartLogic {
	return &CheckedCartLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CheckedCartLogic) CheckedCart(in *cart.CheckedCartRequest) (*cart.CheckedCartResponse, error) {
	_, err := redis.CheckedCart(int(in.Checked))
	if err != nil {
		logx.Error("未选择")
		return nil, err
	}

	return &cart.CheckedCartResponse{
		Success: true,
	}, nil
}
